﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: 2011年7月5日 11:37:43
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections;
#if !CF
using System.Runtime.Serialization;
#endif
using System.Data;
using System.Xml.Serialization;
using CARMSData;
using CARMSData.FactoryClasses;
using CARMSData.DaoClasses;
using CARMSData.RelationClasses;
using CARMSData.HelperClasses;
using CARMSData.CollectionClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace CARMSData.EntityClasses
{
	
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END

	/// <summary>
	/// Entity class which represents the entity 'ReportCategory'. <br/><br/>
	/// 
	/// </summary>
	[Serializable]
	public partial class ReportCategoryEntity : CommonEntityBase, ISerializable
		// __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
		// __LLBLGENPRO_USER_CODE_REGION_END	
	{
		#region Class Member Declarations
		private CARMSData.CollectionClasses.ReportCategoryToTemplateCollection	_reportCategoryToTemplate;
		private bool	_alwaysFetchReportCategoryToTemplate, _alreadyFetchedReportCategoryToTemplate;
		private CARMSData.CollectionClasses.ReportHeaderCollection	_reportHeader;
		private bool	_alwaysFetchReportHeader, _alreadyFetchedReportHeader;
		private CARMSData.CollectionClasses.ReportPropertyCollection	_reportProperty;
		private bool	_alwaysFetchReportProperty, _alreadyFetchedReportProperty;
		private CARMSData.CollectionClasses.TemplateToReportCategoryCollection	_templateToReportCategory;
		private bool	_alwaysFetchTemplateToReportCategory, _alreadyFetchedTemplateToReportCategory;
		private CARMSData.CollectionClasses.UserPermissionCollection	_userPermission;
		private bool	_alwaysFetchUserPermission, _alreadyFetchedUserPermission;
		private CARMSData.CollectionClasses.ReportFlowCollection _reportFlowCollectionViaReportHeader;
		private bool	_alwaysFetchReportFlowCollectionViaReportHeader, _alreadyFetchedReportFlowCollectionViaReportHeader;
		private CARMSData.CollectionClasses.TemplateCollection _templateCollectionViaTemplateToReportCategory;
		private bool	_alwaysFetchTemplateCollectionViaTemplateToReportCategory, _alreadyFetchedTemplateCollectionViaTemplateToReportCategory;
		private CARMSData.CollectionClasses.TemplateCollection _templateCollectionViaReportCategoryToTemplate;
		private bool	_alwaysFetchTemplateCollectionViaReportCategoryToTemplate, _alreadyFetchedTemplateCollectionViaReportCategoryToTemplate;
		private CARMSData.CollectionClasses.UserCollection _userCollectionViaUserPermission;
		private bool	_alwaysFetchUserCollectionViaUserPermission, _alreadyFetchedUserCollectionViaUserPermission;
		private CARMSData.CollectionClasses.UserCollection _userCollectionViaReportHeader;
		private bool	_alwaysFetchUserCollectionViaReportHeader, _alreadyFetchedUserCollectionViaReportHeader;


		
		// __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region Statics
		private static Dictionary<string, string>	_customProperties;
		private static Dictionary<string, Dictionary<string, string>>	_fieldsCustomProperties;

		/// <summary>All names of fields mapped onto a relation. Usable for in-memory filtering</summary>
		public static partial class MemberNames
		{

			/// <summary>Member name ReportCategoryToTemplate</summary>
			public static readonly string ReportCategoryToTemplate = "ReportCategoryToTemplate";
			/// <summary>Member name ReportHeader</summary>
			public static readonly string ReportHeader = "ReportHeader";
			/// <summary>Member name ReportProperty</summary>
			public static readonly string ReportProperty = "ReportProperty";
			/// <summary>Member name TemplateToReportCategory</summary>
			public static readonly string TemplateToReportCategory = "TemplateToReportCategory";
			/// <summary>Member name UserPermission</summary>
			public static readonly string UserPermission = "UserPermission";
			/// <summary>Member name ReportFlowCollectionViaReportHeader</summary>
			public static readonly string ReportFlowCollectionViaReportHeader = "ReportFlowCollectionViaReportHeader";
			/// <summary>Member name TemplateCollectionViaTemplateToReportCategory</summary>
			public static readonly string TemplateCollectionViaTemplateToReportCategory = "TemplateCollectionViaTemplateToReportCategory";
			/// <summary>Member name TemplateCollectionViaReportCategoryToTemplate</summary>
			public static readonly string TemplateCollectionViaReportCategoryToTemplate = "TemplateCollectionViaReportCategoryToTemplate";
			/// <summary>Member name UserCollectionViaUserPermission</summary>
			public static readonly string UserCollectionViaUserPermission = "UserCollectionViaUserPermission";
			/// <summary>Member name UserCollectionViaReportHeader</summary>
			public static readonly string UserCollectionViaReportHeader = "UserCollectionViaReportHeader";

		}
		#endregion
		
		/// <summary>Static CTor for setting up custom property hashtables. Is executed before the first instance of this entity class or derived classes is constructed. </summary>
		static ReportCategoryEntity()
		{
			SetupCustomPropertyHashtables();
		}

		/// <summary>CTor</summary>
		public ReportCategoryEntity()
		{
			InitClassEmpty(null);
		}


		/// <summary>CTor</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		public ReportCategoryEntity(System.Int32 reportCategoryId)
		{
			InitClassFetch(reportCategoryId, null, null);
		}

		/// <summary>CTor</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		public ReportCategoryEntity(System.Int32 reportCategoryId, IPrefetchPath prefetchPathToUse)
		{
			InitClassFetch(reportCategoryId, null, prefetchPathToUse);
		}

		/// <summary>CTor</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <param name="validator">The custom validator object for this ReportCategoryEntity</param>
		public ReportCategoryEntity(System.Int32 reportCategoryId, IValidator validator)
		{
			InitClassFetch(reportCategoryId, validator, null);
		}


		/// <summary>Private CTor for deserialization</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected ReportCategoryEntity(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			_reportCategoryToTemplate = (CARMSData.CollectionClasses.ReportCategoryToTemplateCollection)info.GetValue("_reportCategoryToTemplate", typeof(CARMSData.CollectionClasses.ReportCategoryToTemplateCollection));
			_alwaysFetchReportCategoryToTemplate = info.GetBoolean("_alwaysFetchReportCategoryToTemplate");
			_alreadyFetchedReportCategoryToTemplate = info.GetBoolean("_alreadyFetchedReportCategoryToTemplate");
			_reportHeader = (CARMSData.CollectionClasses.ReportHeaderCollection)info.GetValue("_reportHeader", typeof(CARMSData.CollectionClasses.ReportHeaderCollection));
			_alwaysFetchReportHeader = info.GetBoolean("_alwaysFetchReportHeader");
			_alreadyFetchedReportHeader = info.GetBoolean("_alreadyFetchedReportHeader");
			_reportProperty = (CARMSData.CollectionClasses.ReportPropertyCollection)info.GetValue("_reportProperty", typeof(CARMSData.CollectionClasses.ReportPropertyCollection));
			_alwaysFetchReportProperty = info.GetBoolean("_alwaysFetchReportProperty");
			_alreadyFetchedReportProperty = info.GetBoolean("_alreadyFetchedReportProperty");
			_templateToReportCategory = (CARMSData.CollectionClasses.TemplateToReportCategoryCollection)info.GetValue("_templateToReportCategory", typeof(CARMSData.CollectionClasses.TemplateToReportCategoryCollection));
			_alwaysFetchTemplateToReportCategory = info.GetBoolean("_alwaysFetchTemplateToReportCategory");
			_alreadyFetchedTemplateToReportCategory = info.GetBoolean("_alreadyFetchedTemplateToReportCategory");
			_userPermission = (CARMSData.CollectionClasses.UserPermissionCollection)info.GetValue("_userPermission", typeof(CARMSData.CollectionClasses.UserPermissionCollection));
			_alwaysFetchUserPermission = info.GetBoolean("_alwaysFetchUserPermission");
			_alreadyFetchedUserPermission = info.GetBoolean("_alreadyFetchedUserPermission");
			_reportFlowCollectionViaReportHeader = (CARMSData.CollectionClasses.ReportFlowCollection)info.GetValue("_reportFlowCollectionViaReportHeader", typeof(CARMSData.CollectionClasses.ReportFlowCollection));
			_alwaysFetchReportFlowCollectionViaReportHeader = info.GetBoolean("_alwaysFetchReportFlowCollectionViaReportHeader");
			_alreadyFetchedReportFlowCollectionViaReportHeader = info.GetBoolean("_alreadyFetchedReportFlowCollectionViaReportHeader");
			_templateCollectionViaTemplateToReportCategory = (CARMSData.CollectionClasses.TemplateCollection)info.GetValue("_templateCollectionViaTemplateToReportCategory", typeof(CARMSData.CollectionClasses.TemplateCollection));
			_alwaysFetchTemplateCollectionViaTemplateToReportCategory = info.GetBoolean("_alwaysFetchTemplateCollectionViaTemplateToReportCategory");
			_alreadyFetchedTemplateCollectionViaTemplateToReportCategory = info.GetBoolean("_alreadyFetchedTemplateCollectionViaTemplateToReportCategory");
			_templateCollectionViaReportCategoryToTemplate = (CARMSData.CollectionClasses.TemplateCollection)info.GetValue("_templateCollectionViaReportCategoryToTemplate", typeof(CARMSData.CollectionClasses.TemplateCollection));
			_alwaysFetchTemplateCollectionViaReportCategoryToTemplate = info.GetBoolean("_alwaysFetchTemplateCollectionViaReportCategoryToTemplate");
			_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate = info.GetBoolean("_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate");
			_userCollectionViaUserPermission = (CARMSData.CollectionClasses.UserCollection)info.GetValue("_userCollectionViaUserPermission", typeof(CARMSData.CollectionClasses.UserCollection));
			_alwaysFetchUserCollectionViaUserPermission = info.GetBoolean("_alwaysFetchUserCollectionViaUserPermission");
			_alreadyFetchedUserCollectionViaUserPermission = info.GetBoolean("_alreadyFetchedUserCollectionViaUserPermission");
			_userCollectionViaReportHeader = (CARMSData.CollectionClasses.UserCollection)info.GetValue("_userCollectionViaReportHeader", typeof(CARMSData.CollectionClasses.UserCollection));
			_alwaysFetchUserCollectionViaReportHeader = info.GetBoolean("_alwaysFetchUserCollectionViaReportHeader");
			_alreadyFetchedUserCollectionViaReportHeader = info.GetBoolean("_alreadyFetchedUserCollectionViaReportHeader");


			base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
			
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
		}

		
		/// <summary>Performs the desync setup when an FK field has been changed. The entity referenced based on the FK field will be dereferenced and sync info will be removed.</summary>
		/// <param name="fieldIndex">The fieldindex.</param>
		protected override void PerformDesyncSetupFKFieldChange(int fieldIndex)
		{
			switch((ReportCategoryFieldIndex)fieldIndex)
			{
				default:
					base.PerformDesyncSetupFKFieldChange(fieldIndex);
					break;
			}
		}
		
		/// <summary>Gets the inheritance info provider instance of the project this entity instance is located in. </summary>
		/// <returns>ready to use inheritance info provider instance.</returns>
		protected override IInheritanceInfoProvider GetInheritanceInfoProvider()
		{
			return InheritanceInfoProviderSingleton.GetInstance();
		}
		
		/// <summary> Will perform post-ReadXml actions</summary>
		protected override void PostReadXmlFixups()
		{
			_alreadyFetchedReportCategoryToTemplate = (_reportCategoryToTemplate.Count > 0);
			_alreadyFetchedReportHeader = (_reportHeader.Count > 0);
			_alreadyFetchedReportProperty = (_reportProperty.Count > 0);
			_alreadyFetchedTemplateToReportCategory = (_templateToReportCategory.Count > 0);
			_alreadyFetchedUserPermission = (_userPermission.Count > 0);
			_alreadyFetchedReportFlowCollectionViaReportHeader = (_reportFlowCollectionViaReportHeader.Count > 0);
			_alreadyFetchedTemplateCollectionViaTemplateToReportCategory = (_templateCollectionViaTemplateToReportCategory.Count > 0);
			_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate = (_templateCollectionViaReportCategoryToTemplate.Count > 0);
			_alreadyFetchedUserCollectionViaUserPermission = (_userCollectionViaUserPermission.Count > 0);
			_alreadyFetchedUserCollectionViaReportHeader = (_userCollectionViaReportHeader.Count > 0);


		}
				
		/// <summary>Gets the relation objects which represent the relation the fieldName specified is mapped on. </summary>
		/// <param name="fieldName">Name of the field mapped onto the relation of which the relation objects have to be obtained.</param>
		/// <returns>RelationCollection with relation object(s) which represent the relation the field is maped on</returns>
		public override RelationCollection GetRelationsForFieldOfType(string fieldName)
		{
			return ReportCategoryEntity.GetRelationsForField(fieldName);
		}

		/// <summary>Gets the relation objects which represent the relation the fieldName specified is mapped on. </summary>
		/// <param name="fieldName">Name of the field mapped onto the relation of which the relation objects have to be obtained.</param>
		/// <returns>RelationCollection with relation object(s) which represent the relation the field is maped on</returns>
		public static RelationCollection GetRelationsForField(string fieldName)
		{
			RelationCollection toReturn = new RelationCollection();
			switch(fieldName)
			{

				case "ReportCategoryToTemplate":
					toReturn.Add(ReportCategoryEntity.Relations.ReportCategoryToTemplateEntityUsingReportCategoryId);
					break;
				case "ReportHeader":
					toReturn.Add(ReportCategoryEntity.Relations.ReportHeaderEntityUsingReportCategoryId);
					break;
				case "ReportProperty":
					toReturn.Add(ReportCategoryEntity.Relations.ReportPropertyEntityUsingReportCategoryId);
					break;
				case "TemplateToReportCategory":
					toReturn.Add(ReportCategoryEntity.Relations.TemplateToReportCategoryEntityUsingReportCategoryId);
					break;
				case "UserPermission":
					toReturn.Add(ReportCategoryEntity.Relations.UserPermissionEntityUsingReportId);
					break;
				case "ReportFlowCollectionViaReportHeader":
					toReturn.Add(ReportCategoryEntity.Relations.ReportHeaderEntityUsingReportCategoryId, "ReportCategoryEntity__", "ReportHeader_", JoinHint.None);
					toReturn.Add(ReportHeaderEntity.Relations.ReportFlowEntityUsingReportFlowId, "ReportHeader_", string.Empty, JoinHint.None);
					break;
				case "TemplateCollectionViaTemplateToReportCategory":
					toReturn.Add(ReportCategoryEntity.Relations.TemplateToReportCategoryEntityUsingReportCategoryId, "ReportCategoryEntity__", "TemplateToReportCategory_", JoinHint.None);
					toReturn.Add(TemplateToReportCategoryEntity.Relations.TemplateEntityUsingTemplateId, "TemplateToReportCategory_", string.Empty, JoinHint.None);
					break;
				case "TemplateCollectionViaReportCategoryToTemplate":
					toReturn.Add(ReportCategoryEntity.Relations.ReportCategoryToTemplateEntityUsingReportCategoryId, "ReportCategoryEntity__", "ReportCategoryToTemplate_", JoinHint.None);
					toReturn.Add(ReportCategoryToTemplateEntity.Relations.TemplateEntityUsingTemplateId, "ReportCategoryToTemplate_", string.Empty, JoinHint.None);
					break;
				case "UserCollectionViaUserPermission":
					toReturn.Add(ReportCategoryEntity.Relations.UserPermissionEntityUsingReportId, "ReportCategoryEntity__", "UserPermission_", JoinHint.None);
					toReturn.Add(UserPermissionEntity.Relations.UserEntityUsingUserId, "UserPermission_", string.Empty, JoinHint.None);
					break;
				case "UserCollectionViaReportHeader":
					toReturn.Add(ReportCategoryEntity.Relations.ReportHeaderEntityUsingReportCategoryId, "ReportCategoryEntity__", "ReportHeader_", JoinHint.None);
					toReturn.Add(ReportHeaderEntity.Relations.UserEntityUsingApplyUserId, "ReportHeader_", string.Empty, JoinHint.None);
					break;

				default:

					break;				
			}
			return toReturn;
		}



		/// <summary> ISerializable member. Does custom serialization so event handlers do not get serialized.
		/// Serializes members of this entity class and uses the base class' implementation to serialize the rest.</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			info.AddValue("_reportCategoryToTemplate", (!this.MarkedForDeletion?_reportCategoryToTemplate:null));
			info.AddValue("_alwaysFetchReportCategoryToTemplate", _alwaysFetchReportCategoryToTemplate);
			info.AddValue("_alreadyFetchedReportCategoryToTemplate", _alreadyFetchedReportCategoryToTemplate);
			info.AddValue("_reportHeader", (!this.MarkedForDeletion?_reportHeader:null));
			info.AddValue("_alwaysFetchReportHeader", _alwaysFetchReportHeader);
			info.AddValue("_alreadyFetchedReportHeader", _alreadyFetchedReportHeader);
			info.AddValue("_reportProperty", (!this.MarkedForDeletion?_reportProperty:null));
			info.AddValue("_alwaysFetchReportProperty", _alwaysFetchReportProperty);
			info.AddValue("_alreadyFetchedReportProperty", _alreadyFetchedReportProperty);
			info.AddValue("_templateToReportCategory", (!this.MarkedForDeletion?_templateToReportCategory:null));
			info.AddValue("_alwaysFetchTemplateToReportCategory", _alwaysFetchTemplateToReportCategory);
			info.AddValue("_alreadyFetchedTemplateToReportCategory", _alreadyFetchedTemplateToReportCategory);
			info.AddValue("_userPermission", (!this.MarkedForDeletion?_userPermission:null));
			info.AddValue("_alwaysFetchUserPermission", _alwaysFetchUserPermission);
			info.AddValue("_alreadyFetchedUserPermission", _alreadyFetchedUserPermission);
			info.AddValue("_reportFlowCollectionViaReportHeader", (!this.MarkedForDeletion?_reportFlowCollectionViaReportHeader:null));
			info.AddValue("_alwaysFetchReportFlowCollectionViaReportHeader", _alwaysFetchReportFlowCollectionViaReportHeader);
			info.AddValue("_alreadyFetchedReportFlowCollectionViaReportHeader", _alreadyFetchedReportFlowCollectionViaReportHeader);
			info.AddValue("_templateCollectionViaTemplateToReportCategory", (!this.MarkedForDeletion?_templateCollectionViaTemplateToReportCategory:null));
			info.AddValue("_alwaysFetchTemplateCollectionViaTemplateToReportCategory", _alwaysFetchTemplateCollectionViaTemplateToReportCategory);
			info.AddValue("_alreadyFetchedTemplateCollectionViaTemplateToReportCategory", _alreadyFetchedTemplateCollectionViaTemplateToReportCategory);
			info.AddValue("_templateCollectionViaReportCategoryToTemplate", (!this.MarkedForDeletion?_templateCollectionViaReportCategoryToTemplate:null));
			info.AddValue("_alwaysFetchTemplateCollectionViaReportCategoryToTemplate", _alwaysFetchTemplateCollectionViaReportCategoryToTemplate);
			info.AddValue("_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate", _alreadyFetchedTemplateCollectionViaReportCategoryToTemplate);
			info.AddValue("_userCollectionViaUserPermission", (!this.MarkedForDeletion?_userCollectionViaUserPermission:null));
			info.AddValue("_alwaysFetchUserCollectionViaUserPermission", _alwaysFetchUserCollectionViaUserPermission);
			info.AddValue("_alreadyFetchedUserCollectionViaUserPermission", _alreadyFetchedUserCollectionViaUserPermission);
			info.AddValue("_userCollectionViaReportHeader", (!this.MarkedForDeletion?_userCollectionViaReportHeader:null));
			info.AddValue("_alwaysFetchUserCollectionViaReportHeader", _alwaysFetchUserCollectionViaReportHeader);
			info.AddValue("_alreadyFetchedUserCollectionViaReportHeader", _alreadyFetchedUserCollectionViaReportHeader);


			
			// __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo
			// __LLBLGENPRO_USER_CODE_REGION_END
			base.GetObjectData(info, context);
		}
		
		/// <summary> Sets the related entity property to the entity specified. If the property is a collection, it will add the entity specified to that collection.</summary>
		/// <param name="propertyName">Name of the property.</param>
		/// <param name="entity">Entity to set as an related entity</param>
		/// <remarks>Used by prefetch path logic.</remarks>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntityProperty(string propertyName, IEntity entity)
		{
			switch(propertyName)
			{

				case "ReportCategoryToTemplate":
					_alreadyFetchedReportCategoryToTemplate = true;
					if(entity!=null)
					{
						this.ReportCategoryToTemplate.Add((ReportCategoryToTemplateEntity)entity);
					}
					break;
				case "ReportHeader":
					_alreadyFetchedReportHeader = true;
					if(entity!=null)
					{
						this.ReportHeader.Add((ReportHeaderEntity)entity);
					}
					break;
				case "ReportProperty":
					_alreadyFetchedReportProperty = true;
					if(entity!=null)
					{
						this.ReportProperty.Add((ReportPropertyEntity)entity);
					}
					break;
				case "TemplateToReportCategory":
					_alreadyFetchedTemplateToReportCategory = true;
					if(entity!=null)
					{
						this.TemplateToReportCategory.Add((TemplateToReportCategoryEntity)entity);
					}
					break;
				case "UserPermission":
					_alreadyFetchedUserPermission = true;
					if(entity!=null)
					{
						this.UserPermission.Add((UserPermissionEntity)entity);
					}
					break;
				case "ReportFlowCollectionViaReportHeader":
					_alreadyFetchedReportFlowCollectionViaReportHeader = true;
					if(entity!=null)
					{
						this.ReportFlowCollectionViaReportHeader.Add((ReportFlowEntity)entity);
					}
					break;
				case "TemplateCollectionViaTemplateToReportCategory":
					_alreadyFetchedTemplateCollectionViaTemplateToReportCategory = true;
					if(entity!=null)
					{
						this.TemplateCollectionViaTemplateToReportCategory.Add((TemplateEntity)entity);
					}
					break;
				case "TemplateCollectionViaReportCategoryToTemplate":
					_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate = true;
					if(entity!=null)
					{
						this.TemplateCollectionViaReportCategoryToTemplate.Add((TemplateEntity)entity);
					}
					break;
				case "UserCollectionViaUserPermission":
					_alreadyFetchedUserCollectionViaUserPermission = true;
					if(entity!=null)
					{
						this.UserCollectionViaUserPermission.Add((UserEntity)entity);
					}
					break;
				case "UserCollectionViaReportHeader":
					_alreadyFetchedUserCollectionViaReportHeader = true;
					if(entity!=null)
					{
						this.UserCollectionViaReportHeader.Add((UserEntity)entity);
					}
					break;

				default:

					break;
			}
		}

		/// <summary> Sets the internal parameter related to the fieldname passed to the instance relatedEntity. </summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntity(IEntity relatedEntity, string fieldName)
		{
			switch(fieldName)
			{

				case "ReportCategoryToTemplate":
					_reportCategoryToTemplate.Add((ReportCategoryToTemplateEntity)relatedEntity);
					break;
				case "ReportHeader":
					_reportHeader.Add((ReportHeaderEntity)relatedEntity);
					break;
				case "ReportProperty":
					_reportProperty.Add((ReportPropertyEntity)relatedEntity);
					break;
				case "TemplateToReportCategory":
					_templateToReportCategory.Add((TemplateToReportCategoryEntity)relatedEntity);
					break;
				case "UserPermission":
					_userPermission.Add((UserPermissionEntity)relatedEntity);
					break;

				default:

					break;
			}
		}
		
		/// <summary> Unsets the internal parameter related to the fieldname passed to the instance relatedEntity. Reverses the actions taken by SetRelatedEntity() </summary>
		/// <param name="relatedEntity">Instance to unset as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		/// <param name="signalRelatedEntityManyToOne">if set to true it will notify the manytoone side, if applicable.</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void UnsetRelatedEntity(IEntity relatedEntity, string fieldName, bool signalRelatedEntityManyToOne)
		{
			switch(fieldName)
			{

				case "ReportCategoryToTemplate":
					base.PerformRelatedEntityRemoval(_reportCategoryToTemplate, relatedEntity, signalRelatedEntityManyToOne);
					break;
				case "ReportHeader":
					base.PerformRelatedEntityRemoval(_reportHeader, relatedEntity, signalRelatedEntityManyToOne);
					break;
				case "ReportProperty":
					base.PerformRelatedEntityRemoval(_reportProperty, relatedEntity, signalRelatedEntityManyToOne);
					break;
				case "TemplateToReportCategory":
					base.PerformRelatedEntityRemoval(_templateToReportCategory, relatedEntity, signalRelatedEntityManyToOne);
					break;
				case "UserPermission":
					base.PerformRelatedEntityRemoval(_userPermission, relatedEntity, signalRelatedEntityManyToOne);
					break;

				default:

					break;
			}
		}

		/// <summary> Gets a collection of related entities referenced by this entity which depend on this entity (this entity is the PK side of their FK fields). These
		/// entities will have to be persisted after this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override List<IEntity> GetDependingRelatedEntities()
		{
			List<IEntity> toReturn = new List<IEntity>();


			return toReturn;
		}
		
		/// <summary> Gets a collection of related entities referenced by this entity which this entity depends on (this entity is the FK side of their PK fields). These
		/// entities will have to be persisted before this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override List<IEntity> GetDependentRelatedEntities()
		{
			List<IEntity> toReturn = new List<IEntity>();



			return toReturn;
		}
		
		/// <summary> Gets a List of all entity collections stored as member variables in this entity. The contents of the ArrayList is
		/// used by the DataAccessAdapter to perform recursive saves. Only 1:n related collections are returned.</summary>
		/// <returns>Collection with 0 or more IEntityCollection objects, referenced by this entity</returns>
		public override List<IEntityCollection> GetMemberEntityCollections()
		{
			List<IEntityCollection> toReturn = new List<IEntityCollection>();
			toReturn.Add(_reportCategoryToTemplate);
			toReturn.Add(_reportHeader);
			toReturn.Add(_reportProperty);
			toReturn.Add(_templateToReportCategory);
			toReturn.Add(_userPermission);

			return toReturn;
		}

		

		

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportCategoryId)
		{
			return FetchUsingPK(reportCategoryId, null, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportCategoryId, IPrefetchPath prefetchPathToUse)
		{
			return FetchUsingPK(reportCategoryId, prefetchPathToUse, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportCategoryId, IPrefetchPath prefetchPathToUse, Context contextToUse)
		{
			return Fetch(reportCategoryId, prefetchPathToUse, contextToUse, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <param name="excludedIncludedFields">The list of IEntityField objects which have to be excluded or included for the fetch. 
		/// If null or empty, all fields are fetched (default). If an instance of ExcludeIncludeFieldsList is passed in and its ExcludeContainedFields property
		/// is set to false, the fields contained in excludedIncludedFields are kept in the query, the rest of the fields in the query are excluded.</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 reportCategoryId, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
		{
			return Fetch(reportCategoryId, prefetchPathToUse, contextToUse, excludedIncludedFields);
		}

		/// <summary> Refetches the Entity from the persistent storage. Refetch is used to re-load an Entity which is marked "Out-of-sync", due to a save action. 
		/// Refetching an empty Entity has no effect. </summary>
		/// <returns>true if Refetch succeeded, false otherwise</returns>
		public override bool Refetch()
		{
			return Fetch(this.ReportCategoryId, null, null, null);
		}

		/// <summary> Returns true if the original value for the field with the fieldIndex passed in, read from the persistent storage was NULL, false otherwise.
		/// Should not be used for testing if the current value is NULL, use <see cref="TestCurrentFieldValueForNull"/> for that.</summary>
		/// <param name="fieldIndex">Index of the field to test if that field was NULL in the persistent storage</param>
		/// <returns>true if the field with the passed in index was NULL in the persistent storage, false otherwise</returns>
		public bool TestOriginalFieldValueForNull(ReportCategoryFieldIndex fieldIndex)
		{
			return base.Fields[(int)fieldIndex].IsNull;
		}
		
		/// <summary>Returns true if the current value for the field with the fieldIndex passed in represents null/not defined, false otherwise.
		/// Should not be used for testing if the original value (read from the db) is NULL</summary>
		/// <param name="fieldIndex">Index of the field to test if its currentvalue is null/undefined</param>
		/// <returns>true if the field's value isn't defined yet, false otherwise</returns>
		public bool TestCurrentFieldValueForNull(ReportCategoryFieldIndex fieldIndex)
		{
			return base.CheckIfCurrentFieldValueIsNull((int)fieldIndex);
		}

				
		/// <summary>Gets a list of all the EntityRelation objects the type of this instance has.</summary>
		/// <returns>A list of all the EntityRelation objects the type of this instance has. Hierarchy relations are excluded.</returns>
		public override List<IEntityRelation> GetAllRelations()
		{
			return new ReportCategoryRelations().GetAllRelations();
		}


		/// <summary> Retrieves all related entities of type 'ReportCategoryToTemplateEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ReportCategoryToTemplateEntity'</returns>
		public CARMSData.CollectionClasses.ReportCategoryToTemplateCollection GetMultiReportCategoryToTemplate(bool forceFetch)
		{
			return GetMultiReportCategoryToTemplate(forceFetch, _reportCategoryToTemplate.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportCategoryToTemplateEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ReportCategoryToTemplateEntity'</returns>
		public CARMSData.CollectionClasses.ReportCategoryToTemplateCollection GetMultiReportCategoryToTemplate(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiReportCategoryToTemplate(forceFetch, _reportCategoryToTemplate.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ReportCategoryToTemplateEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.ReportCategoryToTemplateCollection GetMultiReportCategoryToTemplate(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiReportCategoryToTemplate(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportCategoryToTemplateEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual CARMSData.CollectionClasses.ReportCategoryToTemplateCollection GetMultiReportCategoryToTemplate(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedReportCategoryToTemplate || forceFetch || _alwaysFetchReportCategoryToTemplate) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_reportCategoryToTemplate.ParticipatesInTransaction)
					{
						base.Transaction.Add(_reportCategoryToTemplate);
					}
				}
				_reportCategoryToTemplate.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_reportCategoryToTemplate.EntityFactoryToUse = entityFactoryToUse;
				}
				_reportCategoryToTemplate.GetMultiManyToOne(this, null, filter);
				_reportCategoryToTemplate.SuppressClearInGetMulti=false;
				_alreadyFetchedReportCategoryToTemplate = true;
			}
			return _reportCategoryToTemplate;
		}

		/// <summary> Sets the collection parameters for the collection for 'ReportCategoryToTemplate'. These settings will be taken into account
		/// when the property ReportCategoryToTemplate is requested or GetMultiReportCategoryToTemplate is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersReportCategoryToTemplate(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_reportCategoryToTemplate.SortClauses=sortClauses;
			_reportCategoryToTemplate.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ReportHeaderEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ReportHeaderEntity'</returns>
		public CARMSData.CollectionClasses.ReportHeaderCollection GetMultiReportHeader(bool forceFetch)
		{
			return GetMultiReportHeader(forceFetch, _reportHeader.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportHeaderEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ReportHeaderEntity'</returns>
		public CARMSData.CollectionClasses.ReportHeaderCollection GetMultiReportHeader(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiReportHeader(forceFetch, _reportHeader.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ReportHeaderEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.ReportHeaderCollection GetMultiReportHeader(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiReportHeader(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportHeaderEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual CARMSData.CollectionClasses.ReportHeaderCollection GetMultiReportHeader(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedReportHeader || forceFetch || _alwaysFetchReportHeader) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_reportHeader.ParticipatesInTransaction)
					{
						base.Transaction.Add(_reportHeader);
					}
				}
				_reportHeader.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_reportHeader.EntityFactoryToUse = entityFactoryToUse;
				}
				_reportHeader.GetMultiManyToOne(this, null, null, filter);
				_reportHeader.SuppressClearInGetMulti=false;
				_alreadyFetchedReportHeader = true;
			}
			return _reportHeader;
		}

		/// <summary> Sets the collection parameters for the collection for 'ReportHeader'. These settings will be taken into account
		/// when the property ReportHeader is requested or GetMultiReportHeader is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersReportHeader(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_reportHeader.SortClauses=sortClauses;
			_reportHeader.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ReportPropertyEntity'</returns>
		public CARMSData.CollectionClasses.ReportPropertyCollection GetMultiReportProperty(bool forceFetch)
		{
			return GetMultiReportProperty(forceFetch, _reportProperty.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'ReportPropertyEntity'</returns>
		public CARMSData.CollectionClasses.ReportPropertyCollection GetMultiReportProperty(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiReportProperty(forceFetch, _reportProperty.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.ReportPropertyCollection GetMultiReportProperty(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiReportProperty(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual CARMSData.CollectionClasses.ReportPropertyCollection GetMultiReportProperty(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedReportProperty || forceFetch || _alwaysFetchReportProperty) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_reportProperty.ParticipatesInTransaction)
					{
						base.Transaction.Add(_reportProperty);
					}
				}
				_reportProperty.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_reportProperty.EntityFactoryToUse = entityFactoryToUse;
				}
				_reportProperty.GetMultiManyToOne(this, filter);
				_reportProperty.SuppressClearInGetMulti=false;
				_alreadyFetchedReportProperty = true;
			}
			return _reportProperty;
		}

		/// <summary> Sets the collection parameters for the collection for 'ReportProperty'. These settings will be taken into account
		/// when the property ReportProperty is requested or GetMultiReportProperty is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersReportProperty(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_reportProperty.SortClauses=sortClauses;
			_reportProperty.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'TemplateToReportCategoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'TemplateToReportCategoryEntity'</returns>
		public CARMSData.CollectionClasses.TemplateToReportCategoryCollection GetMultiTemplateToReportCategory(bool forceFetch)
		{
			return GetMultiTemplateToReportCategory(forceFetch, _templateToReportCategory.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'TemplateToReportCategoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'TemplateToReportCategoryEntity'</returns>
		public CARMSData.CollectionClasses.TemplateToReportCategoryCollection GetMultiTemplateToReportCategory(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiTemplateToReportCategory(forceFetch, _templateToReportCategory.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'TemplateToReportCategoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.TemplateToReportCategoryCollection GetMultiTemplateToReportCategory(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiTemplateToReportCategory(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'TemplateToReportCategoryEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual CARMSData.CollectionClasses.TemplateToReportCategoryCollection GetMultiTemplateToReportCategory(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedTemplateToReportCategory || forceFetch || _alwaysFetchTemplateToReportCategory) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_templateToReportCategory.ParticipatesInTransaction)
					{
						base.Transaction.Add(_templateToReportCategory);
					}
				}
				_templateToReportCategory.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_templateToReportCategory.EntityFactoryToUse = entityFactoryToUse;
				}
				_templateToReportCategory.GetMultiManyToOne(this, null, filter);
				_templateToReportCategory.SuppressClearInGetMulti=false;
				_alreadyFetchedTemplateToReportCategory = true;
			}
			return _templateToReportCategory;
		}

		/// <summary> Sets the collection parameters for the collection for 'TemplateToReportCategory'. These settings will be taken into account
		/// when the property TemplateToReportCategory is requested or GetMultiTemplateToReportCategory is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersTemplateToReportCategory(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_templateToReportCategory.SortClauses=sortClauses;
			_templateToReportCategory.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'UserPermissionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'UserPermissionEntity'</returns>
		public CARMSData.CollectionClasses.UserPermissionCollection GetMultiUserPermission(bool forceFetch)
		{
			return GetMultiUserPermission(forceFetch, _userPermission.EntityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'UserPermissionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of type 'UserPermissionEntity'</returns>
		public CARMSData.CollectionClasses.UserPermissionCollection GetMultiUserPermission(bool forceFetch, IPredicateExpression filter)
		{
			return GetMultiUserPermission(forceFetch, _userPermission.EntityFactoryToUse, filter);
		}

		/// <summary> Retrieves all related entities of type 'UserPermissionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.UserPermissionCollection GetMultiUserPermission(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
			return GetMultiUserPermission(forceFetch, entityFactoryToUse, null);
		}

		/// <summary> Retrieves all related entities of type 'UserPermissionEntity' using a relation of type '1:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToOne() routine.</param>
		/// <param name="filter">Extra filter to limit the resultset.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public virtual CARMSData.CollectionClasses.UserPermissionCollection GetMultiUserPermission(bool forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter)
		{
 			if( ( !_alreadyFetchedUserPermission || forceFetch || _alwaysFetchUserPermission) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_userPermission.ParticipatesInTransaction)
					{
						base.Transaction.Add(_userPermission);
					}
				}
				_userPermission.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_userPermission.EntityFactoryToUse = entityFactoryToUse;
				}
				_userPermission.GetMultiManyToOne(this, null, filter);
				_userPermission.SuppressClearInGetMulti=false;
				_alreadyFetchedUserPermission = true;
			}
			return _userPermission;
		}

		/// <summary> Sets the collection parameters for the collection for 'UserPermission'. These settings will be taken into account
		/// when the property UserPermission is requested or GetMultiUserPermission is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersUserPermission(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_userPermission.SortClauses=sortClauses;
			_userPermission.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'ReportFlowEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'ReportFlowEntity'</returns>
		public CARMSData.CollectionClasses.ReportFlowCollection GetMultiReportFlowCollectionViaReportHeader(bool forceFetch)
		{
			return GetMultiReportFlowCollectionViaReportHeader(forceFetch, _reportFlowCollectionViaReportHeader.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'ReportFlowEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.ReportFlowCollection GetMultiReportFlowCollectionViaReportHeader(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedReportFlowCollectionViaReportHeader || forceFetch || _alwaysFetchReportFlowCollectionViaReportHeader) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_reportFlowCollectionViaReportHeader.ParticipatesInTransaction)
					{
						base.Transaction.Add(_reportFlowCollectionViaReportHeader);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportCategoryFields.ReportCategoryId, ComparisonOperator.Equal, this.ReportCategoryId, "ReportCategoryEntity__"));
				_reportFlowCollectionViaReportHeader.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_reportFlowCollectionViaReportHeader.EntityFactoryToUse = entityFactoryToUse;
				}
				_reportFlowCollectionViaReportHeader.GetMulti(filter, GetRelationsForField("ReportFlowCollectionViaReportHeader"));
				_reportFlowCollectionViaReportHeader.SuppressClearInGetMulti=false;
				_alreadyFetchedReportFlowCollectionViaReportHeader = true;
			}
			return _reportFlowCollectionViaReportHeader;
		}

		/// <summary> Sets the collection parameters for the collection for 'ReportFlowCollectionViaReportHeader'. These settings will be taken into account
		/// when the property ReportFlowCollectionViaReportHeader is requested or GetMultiReportFlowCollectionViaReportHeader is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersReportFlowCollectionViaReportHeader(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_reportFlowCollectionViaReportHeader.SortClauses=sortClauses;
			_reportFlowCollectionViaReportHeader.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'TemplateEntity'</returns>
		public CARMSData.CollectionClasses.TemplateCollection GetMultiTemplateCollectionViaTemplateToReportCategory(bool forceFetch)
		{
			return GetMultiTemplateCollectionViaTemplateToReportCategory(forceFetch, _templateCollectionViaTemplateToReportCategory.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.TemplateCollection GetMultiTemplateCollectionViaTemplateToReportCategory(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedTemplateCollectionViaTemplateToReportCategory || forceFetch || _alwaysFetchTemplateCollectionViaTemplateToReportCategory) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_templateCollectionViaTemplateToReportCategory.ParticipatesInTransaction)
					{
						base.Transaction.Add(_templateCollectionViaTemplateToReportCategory);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportCategoryFields.ReportCategoryId, ComparisonOperator.Equal, this.ReportCategoryId, "ReportCategoryEntity__"));
				_templateCollectionViaTemplateToReportCategory.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_templateCollectionViaTemplateToReportCategory.EntityFactoryToUse = entityFactoryToUse;
				}
				_templateCollectionViaTemplateToReportCategory.GetMulti(filter, GetRelationsForField("TemplateCollectionViaTemplateToReportCategory"));
				_templateCollectionViaTemplateToReportCategory.SuppressClearInGetMulti=false;
				_alreadyFetchedTemplateCollectionViaTemplateToReportCategory = true;
			}
			return _templateCollectionViaTemplateToReportCategory;
		}

		/// <summary> Sets the collection parameters for the collection for 'TemplateCollectionViaTemplateToReportCategory'. These settings will be taken into account
		/// when the property TemplateCollectionViaTemplateToReportCategory is requested or GetMultiTemplateCollectionViaTemplateToReportCategory is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersTemplateCollectionViaTemplateToReportCategory(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_templateCollectionViaTemplateToReportCategory.SortClauses=sortClauses;
			_templateCollectionViaTemplateToReportCategory.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'TemplateEntity'</returns>
		public CARMSData.CollectionClasses.TemplateCollection GetMultiTemplateCollectionViaReportCategoryToTemplate(bool forceFetch)
		{
			return GetMultiTemplateCollectionViaReportCategoryToTemplate(forceFetch, _templateCollectionViaReportCategoryToTemplate.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.TemplateCollection GetMultiTemplateCollectionViaReportCategoryToTemplate(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate || forceFetch || _alwaysFetchTemplateCollectionViaReportCategoryToTemplate) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_templateCollectionViaReportCategoryToTemplate.ParticipatesInTransaction)
					{
						base.Transaction.Add(_templateCollectionViaReportCategoryToTemplate);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportCategoryFields.ReportCategoryId, ComparisonOperator.Equal, this.ReportCategoryId, "ReportCategoryEntity__"));
				_templateCollectionViaReportCategoryToTemplate.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_templateCollectionViaReportCategoryToTemplate.EntityFactoryToUse = entityFactoryToUse;
				}
				_templateCollectionViaReportCategoryToTemplate.GetMulti(filter, GetRelationsForField("TemplateCollectionViaReportCategoryToTemplate"));
				_templateCollectionViaReportCategoryToTemplate.SuppressClearInGetMulti=false;
				_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate = true;
			}
			return _templateCollectionViaReportCategoryToTemplate;
		}

		/// <summary> Sets the collection parameters for the collection for 'TemplateCollectionViaReportCategoryToTemplate'. These settings will be taken into account
		/// when the property TemplateCollectionViaReportCategoryToTemplate is requested or GetMultiTemplateCollectionViaReportCategoryToTemplate is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersTemplateCollectionViaReportCategoryToTemplate(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_templateCollectionViaReportCategoryToTemplate.SortClauses=sortClauses;
			_templateCollectionViaReportCategoryToTemplate.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'UserEntity'</returns>
		public CARMSData.CollectionClasses.UserCollection GetMultiUserCollectionViaUserPermission(bool forceFetch)
		{
			return GetMultiUserCollectionViaUserPermission(forceFetch, _userCollectionViaUserPermission.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.UserCollection GetMultiUserCollectionViaUserPermission(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedUserCollectionViaUserPermission || forceFetch || _alwaysFetchUserCollectionViaUserPermission) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_userCollectionViaUserPermission.ParticipatesInTransaction)
					{
						base.Transaction.Add(_userCollectionViaUserPermission);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportCategoryFields.ReportCategoryId, ComparisonOperator.Equal, this.ReportCategoryId, "ReportCategoryEntity__"));
				_userCollectionViaUserPermission.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_userCollectionViaUserPermission.EntityFactoryToUse = entityFactoryToUse;
				}
				_userCollectionViaUserPermission.GetMulti(filter, GetRelationsForField("UserCollectionViaUserPermission"));
				_userCollectionViaUserPermission.SuppressClearInGetMulti=false;
				_alreadyFetchedUserCollectionViaUserPermission = true;
			}
			return _userCollectionViaUserPermission;
		}

		/// <summary> Sets the collection parameters for the collection for 'UserCollectionViaUserPermission'. These settings will be taken into account
		/// when the property UserCollectionViaUserPermission is requested or GetMultiUserCollectionViaUserPermission is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersUserCollectionViaUserPermission(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_userCollectionViaUserPermission.SortClauses=sortClauses;
			_userCollectionViaUserPermission.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <returns>Filled collection with all related entities of type 'UserEntity'</returns>
		public CARMSData.CollectionClasses.UserCollection GetMultiUserCollectionViaReportHeader(bool forceFetch)
		{
			return GetMultiUserCollectionViaReportHeader(forceFetch, _userCollectionViaReportHeader.EntityFactoryToUse);
		}

		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the collection and will rerun the complete query instead</param>
		/// <param name="entityFactoryToUse">The entity factory to use for the GetMultiManyToMany() routine.</param>
		/// <returns>Filled collection with all related entities of the type constructed by the passed in entity factory</returns>
		public CARMSData.CollectionClasses.UserCollection GetMultiUserCollectionViaReportHeader(bool forceFetch, IEntityFactory entityFactoryToUse)
		{
 			if( ( !_alreadyFetchedUserCollectionViaReportHeader || forceFetch || _alwaysFetchUserCollectionViaReportHeader) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode)
			{
				if(base.ParticipatesInTransaction)
				{
					if(!_userCollectionViaReportHeader.ParticipatesInTransaction)
					{
						base.Transaction.Add(_userCollectionViaReportHeader);
					}
				}
				IPredicateExpression filter = new PredicateExpression();
				filter.Add(new FieldCompareValuePredicate(ReportCategoryFields.ReportCategoryId, ComparisonOperator.Equal, this.ReportCategoryId, "ReportCategoryEntity__"));
				_userCollectionViaReportHeader.SuppressClearInGetMulti=!forceFetch;
				if(entityFactoryToUse!=null)
				{
					_userCollectionViaReportHeader.EntityFactoryToUse = entityFactoryToUse;
				}
				_userCollectionViaReportHeader.GetMulti(filter, GetRelationsForField("UserCollectionViaReportHeader"));
				_userCollectionViaReportHeader.SuppressClearInGetMulti=false;
				_alreadyFetchedUserCollectionViaReportHeader = true;
			}
			return _userCollectionViaReportHeader;
		}

		/// <summary> Sets the collection parameters for the collection for 'UserCollectionViaReportHeader'. These settings will be taken into account
		/// when the property UserCollectionViaReportHeader is requested or GetMultiUserCollectionViaReportHeader is called.</summary>
		/// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return. When set to 0, this parameter is ignored</param>
		/// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified (null), no sorting is applied.</param>
		public virtual void SetCollectionParametersUserCollectionViaReportHeader(long maxNumberOfItemsToReturn, ISortExpression sortClauses)
		{
			_userCollectionViaReportHeader.SortClauses=sortClauses;
			_userCollectionViaReportHeader.MaxNumberOfItemsToReturn=maxNumberOfItemsToReturn;
		}



		/// <summary> Performs the insert action of a new Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool InsertEntity()
		{
			ReportCategoryDAO dao = (ReportCategoryDAO)CreateDAOInstance();
			return dao.AddNew(base.Fields, base.Transaction);
		}
		
		/// <summary> Adds the internals to the active context. </summary>
		protected override void AddInternalsToContext()
		{
			_reportCategoryToTemplate.ActiveContext = base.ActiveContext;
			_reportHeader.ActiveContext = base.ActiveContext;
			_reportProperty.ActiveContext = base.ActiveContext;
			_templateToReportCategory.ActiveContext = base.ActiveContext;
			_userPermission.ActiveContext = base.ActiveContext;
			_reportFlowCollectionViaReportHeader.ActiveContext = base.ActiveContext;
			_templateCollectionViaTemplateToReportCategory.ActiveContext = base.ActiveContext;
			_templateCollectionViaReportCategoryToTemplate.ActiveContext = base.ActiveContext;
			_userCollectionViaUserPermission.ActiveContext = base.ActiveContext;
			_userCollectionViaReportHeader.ActiveContext = base.ActiveContext;



		}


		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity()
		{
			ReportCategoryDAO dao = (ReportCategoryDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction);
		}
		
		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query</param>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity(IPredicate updateRestriction)
		{
			ReportCategoryDAO dao = (ReportCategoryDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction, updateRestriction);
		}
	
		/// <summary> Initializes the class with empty data, as if it is a new Entity.</summary>
		/// <param name="validatorToUse">Validator to use.</param>
		protected virtual void InitClassEmpty(IValidator validatorToUse)
		{
			OnInitializing();
			base.Fields = CreateFields();
			base.IsNew=true;
			base.Validator = validatorToUse;

			InitClassMembers();
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}
		
		/// <summary>Creates entity fields object for this entity. Used in constructor to setup this entity in a polymorphic scenario.</summary>
		protected virtual IEntityFields CreateFields()
		{
			return EntityFieldsFactory.CreateEntityFieldsObject(CARMSData.EntityType.ReportCategoryEntity);
		}
		
		/// <summary>Creates a new transaction object</summary>
		/// <param name="levelOfIsolation">The level of isolation.</param>
		/// <param name="name">The name.</param>
		protected override ITransaction CreateTransaction( IsolationLevel levelOfIsolation, string name )
		{
			return new Transaction(levelOfIsolation, name);
		}

		/// <summary>
		/// Creates the ITypeDefaultValue instance used to provide default values for value types which aren't of type nullable(of T)
		/// </summary>
		/// <returns></returns>
		protected override ITypeDefaultValue CreateTypeDefaultValueProvider()
		{
			return new TypeDefaultValue();
		}

		/// <summary>
		/// Gets all related data objects, stored by name. The name is the field name mapped onto the relation for that particular data element. 
		/// </summary>
		/// <returns>Dictionary with per name the related referenced data element, which can be an entity collection or an entity or null</returns>
		public override Dictionary<string, object> GetRelatedData()
		{
			Dictionary<string, object> toReturn = new Dictionary<string, object>();

			toReturn.Add("ReportCategoryToTemplate", _reportCategoryToTemplate);
			toReturn.Add("ReportHeader", _reportHeader);
			toReturn.Add("ReportProperty", _reportProperty);
			toReturn.Add("TemplateToReportCategory", _templateToReportCategory);
			toReturn.Add("UserPermission", _userPermission);
			toReturn.Add("ReportFlowCollectionViaReportHeader", _reportFlowCollectionViaReportHeader);
			toReturn.Add("TemplateCollectionViaTemplateToReportCategory", _templateCollectionViaTemplateToReportCategory);
			toReturn.Add("TemplateCollectionViaReportCategoryToTemplate", _templateCollectionViaReportCategoryToTemplate);
			toReturn.Add("UserCollectionViaUserPermission", _userCollectionViaUserPermission);
			toReturn.Add("UserCollectionViaReportHeader", _userCollectionViaReportHeader);

			return toReturn;
		}
		

		/// <summary> Initializes the the entity and fetches the data related to the entity in this entity.</summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <param name="validator">The validator object for this ReportCategoryEntity</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		protected virtual void InitClassFetch(System.Int32 reportCategoryId, IValidator validator, IPrefetchPath prefetchPathToUse)
		{
			OnInitializing();
			base.Validator = validator;
			InitClassMembers();
			base.Fields = CreateFields();
			bool wasSuccesful = Fetch(reportCategoryId, prefetchPathToUse, null, null);
			base.IsNew = !wasSuccesful;

			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassFetch
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}

		/// <summary> Initializes the class members</summary>
		private void InitClassMembers()
		{
			_reportCategoryToTemplate = new CARMSData.CollectionClasses.ReportCategoryToTemplateCollection(new ReportCategoryToTemplateEntityFactory());
			_reportCategoryToTemplate.SetContainingEntityInfo(this, "ReportCategory");
			_alwaysFetchReportCategoryToTemplate = false;
			_alreadyFetchedReportCategoryToTemplate = false;
			_reportHeader = new CARMSData.CollectionClasses.ReportHeaderCollection(new ReportHeaderEntityFactory());
			_reportHeader.SetContainingEntityInfo(this, "ReportCategory");
			_alwaysFetchReportHeader = false;
			_alreadyFetchedReportHeader = false;
			_reportProperty = new CARMSData.CollectionClasses.ReportPropertyCollection(new ReportPropertyEntityFactory());
			_reportProperty.SetContainingEntityInfo(this, "ReportCategory");
			_alwaysFetchReportProperty = false;
			_alreadyFetchedReportProperty = false;
			_templateToReportCategory = new CARMSData.CollectionClasses.TemplateToReportCategoryCollection(new TemplateToReportCategoryEntityFactory());
			_templateToReportCategory.SetContainingEntityInfo(this, "ReportCategory");
			_alwaysFetchTemplateToReportCategory = false;
			_alreadyFetchedTemplateToReportCategory = false;
			_userPermission = new CARMSData.CollectionClasses.UserPermissionCollection(new UserPermissionEntityFactory());
			_userPermission.SetContainingEntityInfo(this, "ReportCategory");
			_alwaysFetchUserPermission = false;
			_alreadyFetchedUserPermission = false;
			_reportFlowCollectionViaReportHeader = new CARMSData.CollectionClasses.ReportFlowCollection(new ReportFlowEntityFactory());
			_alwaysFetchReportFlowCollectionViaReportHeader = false;
			_alreadyFetchedReportFlowCollectionViaReportHeader = false;
			_templateCollectionViaTemplateToReportCategory = new CARMSData.CollectionClasses.TemplateCollection(new TemplateEntityFactory());
			_alwaysFetchTemplateCollectionViaTemplateToReportCategory = false;
			_alreadyFetchedTemplateCollectionViaTemplateToReportCategory = false;
			_templateCollectionViaReportCategoryToTemplate = new CARMSData.CollectionClasses.TemplateCollection(new TemplateEntityFactory());
			_alwaysFetchTemplateCollectionViaReportCategoryToTemplate = false;
			_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate = false;
			_userCollectionViaUserPermission = new CARMSData.CollectionClasses.UserCollection(new UserEntityFactory());
			_alwaysFetchUserCollectionViaUserPermission = false;
			_alreadyFetchedUserCollectionViaUserPermission = false;
			_userCollectionViaReportHeader = new CARMSData.CollectionClasses.UserCollection(new UserEntityFactory());
			_alwaysFetchUserCollectionViaReportHeader = false;
			_alreadyFetchedUserCollectionViaReportHeader = false;



			PerformDependencyInjection();
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
			// __LLBLGENPRO_USER_CODE_REGION_END
			OnInitClassMembersComplete();
		}

		#region Custom Property Hashtable Setup
		/// <summary> Initializes the hashtables for the entity type and entity field custom properties. </summary>
		private static void SetupCustomPropertyHashtables()
		{
			_customProperties = new Dictionary<string, string>();
			_fieldsCustomProperties = new Dictionary<string, Dictionary<string, string>>();

			Dictionary<string, string> fieldHashtable = null;
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ReportCategoryId", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ReportCategoryName", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("CreateDate", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ReportCategoryType", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("BodyTableName", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("CreationUrl", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ApproveUserId", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("ViewUrl", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("G1307", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("G1308", fieldHashtable);
			fieldHashtable = new Dictionary<string, string>();

			_fieldsCustomProperties.Add("IsFlowStart", fieldHashtable);
		}
		#endregion




		/// <summary> Fetches the entity from the persistent storage. Fetch simply reads the entity into an EntityFields object. </summary>
		/// <param name="reportCategoryId">PK value for ReportCategory which data should be fetched into this ReportCategory object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <param name="excludedIncludedFields">The list of IEntityField objects which have to be excluded or included for the fetch. 
		/// If null or empty, all fields are fetched (default). If an instance of ExcludeIncludeFieldsList is passed in and its ExcludeContainedFields property
		/// is set to false, the fields contained in excludedIncludedFields are kept in the query, the rest of the fields in the query are excluded.</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		private bool Fetch(System.Int32 reportCategoryId, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
		{
			try
			{
				OnFetch();
				IDao dao = this.CreateDAOInstance();
				base.Fields[(int)ReportCategoryFieldIndex.ReportCategoryId].ForcedCurrentValueWrite(reportCategoryId);
				dao.FetchExisting(this, base.Transaction, prefetchPathToUse, contextToUse, excludedIncludedFields);
				return (base.Fields.State == EntityState.Fetched);
			}
			finally
			{
				OnFetchComplete();
			}
		}


		/// <summary> Creates the DAO instance for this type</summary>
		/// <returns></returns>
		protected override IDao CreateDAOInstance()
		{
			return DAOFactory.CreateReportCategoryDAO();
		}
		
		/// <summary> Creates the entity factory for this type.</summary>
		/// <returns></returns>
		protected override IEntityFactory CreateEntityFactory()
		{
			return new ReportCategoryEntityFactory();
		}

		#region Class Property Declarations
		/// <summary> The relations object holding all relations of this entity with other entity classes.</summary>
		public  static ReportCategoryRelations Relations
		{
			get	{ return new ReportCategoryRelations(); }
		}
		
		/// <summary> The custom properties for this entity type.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Dictionary<string, string> CustomProperties
		{
			get { return _customProperties;}
		}


		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportCategoryToTemplate' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportCategoryToTemplate
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportCategoryToTemplateCollection(),
					(IEntityRelation)GetRelationsForField("ReportCategoryToTemplate")[0], (int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.ReportCategoryToTemplateEntity, 0, null, null, null, "ReportCategoryToTemplate", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportHeader' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportHeader
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportHeaderCollection(),
					(IEntityRelation)GetRelationsForField("ReportHeader")[0], (int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.ReportHeaderEntity, 0, null, null, null, "ReportHeader", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportProperty' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportProperty
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportPropertyCollection(),
					(IEntityRelation)GetRelationsForField("ReportProperty")[0], (int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.ReportPropertyEntity, 0, null, null, null, "ReportProperty", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'TemplateToReportCategory' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathTemplateToReportCategory
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.TemplateToReportCategoryCollection(),
					(IEntityRelation)GetRelationsForField("TemplateToReportCategory")[0], (int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.TemplateToReportCategoryEntity, 0, null, null, null, "TemplateToReportCategory", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'UserPermission' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUserPermission
		{
			get
			{
				return new PrefetchPathElement(new CARMSData.CollectionClasses.UserPermissionCollection(),
					(IEntityRelation)GetRelationsForField("UserPermission")[0], (int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.UserPermissionEntity, 0, null, null, null, "UserPermission", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'ReportFlow' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathReportFlowCollectionViaReportHeader
		{
			get
			{
				IEntityRelation intermediateRelation = ReportCategoryEntity.Relations.ReportHeaderEntityUsingReportCategoryId;
				intermediateRelation.SetAliases(string.Empty, "ReportHeader_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.ReportFlowCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.ReportFlowEntity, 0, null, null, GetRelationsForField("ReportFlowCollectionViaReportHeader"), "ReportFlowCollectionViaReportHeader", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Template' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathTemplateCollectionViaTemplateToReportCategory
		{
			get
			{
				IEntityRelation intermediateRelation = ReportCategoryEntity.Relations.TemplateToReportCategoryEntityUsingReportCategoryId;
				intermediateRelation.SetAliases(string.Empty, "TemplateToReportCategory_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.TemplateCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.TemplateEntity, 0, null, null, GetRelationsForField("TemplateCollectionViaTemplateToReportCategory"), "TemplateCollectionViaTemplateToReportCategory", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Template' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathTemplateCollectionViaReportCategoryToTemplate
		{
			get
			{
				IEntityRelation intermediateRelation = ReportCategoryEntity.Relations.ReportCategoryToTemplateEntityUsingReportCategoryId;
				intermediateRelation.SetAliases(string.Empty, "ReportCategoryToTemplate_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.TemplateCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.TemplateEntity, 0, null, null, GetRelationsForField("TemplateCollectionViaReportCategoryToTemplate"), "TemplateCollectionViaReportCategoryToTemplate", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'User' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUserCollectionViaUserPermission
		{
			get
			{
				IEntityRelation intermediateRelation = ReportCategoryEntity.Relations.UserPermissionEntityUsingReportId;
				intermediateRelation.SetAliases(string.Empty, "UserPermission_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.UserCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.UserEntity, 0, null, null, GetRelationsForField("UserCollectionViaUserPermission"), "UserCollectionViaUserPermission", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'User' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathUserCollectionViaReportHeader
		{
			get
			{
				IEntityRelation intermediateRelation = ReportCategoryEntity.Relations.ReportHeaderEntityUsingReportCategoryId;
				intermediateRelation.SetAliases(string.Empty, "ReportHeader_");
				return new PrefetchPathElement(new CARMSData.CollectionClasses.UserCollection(), intermediateRelation,
					(int)CARMSData.EntityType.ReportCategoryEntity, (int)CARMSData.EntityType.UserEntity, 0, null, null, GetRelationsForField("UserCollectionViaReportHeader"), "UserCollectionViaReportHeader", SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToMany);
			}
		}



		/// <summary>Returns the full name for this entity, which is important for the DAO to find back persistence info for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override string LLBLGenProEntityName
		{
			get { return "ReportCategoryEntity";}
		}

		/// <summary> The custom properties for the type of this entity instance.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public override Dictionary<string, string> CustomPropertiesOfType
		{
			get { return ReportCategoryEntity.CustomProperties;}
		}

		/// <summary> The custom properties for the fields of this entity type. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Dictionary<string, Dictionary<string, string>> FieldsCustomProperties
		{
			get { return _fieldsCustomProperties;}
		}

		/// <summary> The custom properties for the fields of the type of this entity instance. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public override Dictionary<string, Dictionary<string, string>> FieldsCustomPropertiesOfType
		{
			get { return ReportCategoryEntity.FieldsCustomProperties;}
		}

		/// <summary> The ReportCategoryId property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."ReportCategoryID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, true, true</remarks>
		public virtual System.Int32 ReportCategoryId
		{
			get { return (System.Int32)GetValue((int)ReportCategoryFieldIndex.ReportCategoryId, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.ReportCategoryId, value, true); }
		}
		/// <summary> The ReportCategoryName property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."ReportCategoryName"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String ReportCategoryName
		{
			get { return (System.String)GetValue((int)ReportCategoryFieldIndex.ReportCategoryName, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.ReportCategoryName, value, true); }
		}
		/// <summary> The CreateDate property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."CreateDate"<br/>
		/// Table field type characteristics (type, precision, scale, length): DateTime, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.DateTime CreateDate
		{
			get { return (System.DateTime)GetValue((int)ReportCategoryFieldIndex.CreateDate, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.CreateDate, value, true); }
		}
		/// <summary> The ReportCategoryType property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."ReportCategoryType"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Int32 ReportCategoryType
		{
			get { return (System.Int32)GetValue((int)ReportCategoryFieldIndex.ReportCategoryType, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.ReportCategoryType, value, true); }
		}
		/// <summary> The BodyTableName property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."BodyTableName"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String BodyTableName
		{
			get { return (System.String)GetValue((int)ReportCategoryFieldIndex.BodyTableName, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.BodyTableName, value, true); }
		}
		/// <summary> The CreationUrl property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."CreationUrl"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 200<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String CreationUrl
		{
			get { return (System.String)GetValue((int)ReportCategoryFieldIndex.CreationUrl, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.CreationUrl, value, true); }
		}
		/// <summary> The ApproveUserId property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."ApproveUserID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Int32 ApproveUserId
		{
			get { return (System.Int32)GetValue((int)ReportCategoryFieldIndex.ApproveUserId, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.ApproveUserId, value, true); }
		}
		/// <summary> The ViewUrl property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."ViewUrl"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 200<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String ViewUrl
		{
			get { return (System.String)GetValue((int)ReportCategoryFieldIndex.ViewUrl, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.ViewUrl, value, true); }
		}
		/// <summary> The G1307 property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."G130-7"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String G1307
		{
			get { return (System.String)GetValue((int)ReportCategoryFieldIndex.G1307, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.G1307, value, true); }
		}
		/// <summary> The G1308 property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."G130-8"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String G1308
		{
			get { return (System.String)GetValue((int)ReportCategoryFieldIndex.G1308, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.G1308, value, true); }
		}
		/// <summary> The IsFlowStart property of the Entity ReportCategory<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "ReportCategory"."IsFlowStart"<br/>
		/// Table field type characteristics (type, precision, scale, length): Bit, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Boolean IsFlowStart
		{
			get { return (System.Boolean)GetValue((int)ReportCategoryFieldIndex.IsFlowStart, true); }
			set	{ SetValue((int)ReportCategoryFieldIndex.IsFlowStart, value, true); }
		}

		/// <summary> Retrieves all related entities of type 'ReportCategoryToTemplateEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiReportCategoryToTemplate()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.ReportCategoryToTemplateCollection ReportCategoryToTemplate
		{
			get	{ return GetMultiReportCategoryToTemplate(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ReportCategoryToTemplate. When set to true, ReportCategoryToTemplate is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportCategoryToTemplate is accessed. You can always execute
		/// a forced fetch by calling GetMultiReportCategoryToTemplate(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportCategoryToTemplate
		{
			get	{ return _alwaysFetchReportCategoryToTemplate; }
			set	{ _alwaysFetchReportCategoryToTemplate = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportCategoryToTemplate already has been fetched. Setting this property to false when ReportCategoryToTemplate has been fetched
		/// will clear the ReportCategoryToTemplate collection well. Setting this property to true while ReportCategoryToTemplate hasn't been fetched disables lazy loading for ReportCategoryToTemplate</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportCategoryToTemplate
		{
			get { return _alreadyFetchedReportCategoryToTemplate;}
			set 
			{
				if(_alreadyFetchedReportCategoryToTemplate && !value && (_reportCategoryToTemplate != null))
				{
					_reportCategoryToTemplate.Clear();
				}
				_alreadyFetchedReportCategoryToTemplate = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'ReportHeaderEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiReportHeader()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.ReportHeaderCollection ReportHeader
		{
			get	{ return GetMultiReportHeader(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ReportHeader. When set to true, ReportHeader is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportHeader is accessed. You can always execute
		/// a forced fetch by calling GetMultiReportHeader(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportHeader
		{
			get	{ return _alwaysFetchReportHeader; }
			set	{ _alwaysFetchReportHeader = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportHeader already has been fetched. Setting this property to false when ReportHeader has been fetched
		/// will clear the ReportHeader collection well. Setting this property to true while ReportHeader hasn't been fetched disables lazy loading for ReportHeader</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportHeader
		{
			get { return _alreadyFetchedReportHeader;}
			set 
			{
				if(_alreadyFetchedReportHeader && !value && (_reportHeader != null))
				{
					_reportHeader.Clear();
				}
				_alreadyFetchedReportHeader = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'ReportPropertyEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiReportProperty()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.ReportPropertyCollection ReportProperty
		{
			get	{ return GetMultiReportProperty(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ReportProperty. When set to true, ReportProperty is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportProperty is accessed. You can always execute
		/// a forced fetch by calling GetMultiReportProperty(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportProperty
		{
			get	{ return _alwaysFetchReportProperty; }
			set	{ _alwaysFetchReportProperty = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportProperty already has been fetched. Setting this property to false when ReportProperty has been fetched
		/// will clear the ReportProperty collection well. Setting this property to true while ReportProperty hasn't been fetched disables lazy loading for ReportProperty</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportProperty
		{
			get { return _alreadyFetchedReportProperty;}
			set 
			{
				if(_alreadyFetchedReportProperty && !value && (_reportProperty != null))
				{
					_reportProperty.Clear();
				}
				_alreadyFetchedReportProperty = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'TemplateToReportCategoryEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiTemplateToReportCategory()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.TemplateToReportCategoryCollection TemplateToReportCategory
		{
			get	{ return GetMultiTemplateToReportCategory(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for TemplateToReportCategory. When set to true, TemplateToReportCategory is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time TemplateToReportCategory is accessed. You can always execute
		/// a forced fetch by calling GetMultiTemplateToReportCategory(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchTemplateToReportCategory
		{
			get	{ return _alwaysFetchTemplateToReportCategory; }
			set	{ _alwaysFetchTemplateToReportCategory = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property TemplateToReportCategory already has been fetched. Setting this property to false when TemplateToReportCategory has been fetched
		/// will clear the TemplateToReportCategory collection well. Setting this property to true while TemplateToReportCategory hasn't been fetched disables lazy loading for TemplateToReportCategory</summary>
		[Browsable(false)]
		public bool AlreadyFetchedTemplateToReportCategory
		{
			get { return _alreadyFetchedTemplateToReportCategory;}
			set 
			{
				if(_alreadyFetchedTemplateToReportCategory && !value && (_templateToReportCategory != null))
				{
					_templateToReportCategory.Clear();
				}
				_alreadyFetchedTemplateToReportCategory = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'UserPermissionEntity' using a relation of type '1:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiUserPermission()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.UserPermissionCollection UserPermission
		{
			get	{ return GetMultiUserPermission(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for UserPermission. When set to true, UserPermission is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time UserPermission is accessed. You can always execute
		/// a forced fetch by calling GetMultiUserPermission(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUserPermission
		{
			get	{ return _alwaysFetchUserPermission; }
			set	{ _alwaysFetchUserPermission = value; }	
		}		
				
		/// <summary>Gets / Sets the lazy loading flag if the property UserPermission already has been fetched. Setting this property to false when UserPermission has been fetched
		/// will clear the UserPermission collection well. Setting this property to true while UserPermission hasn't been fetched disables lazy loading for UserPermission</summary>
		[Browsable(false)]
		public bool AlreadyFetchedUserPermission
		{
			get { return _alreadyFetchedUserPermission;}
			set 
			{
				if(_alreadyFetchedUserPermission && !value && (_userPermission != null))
				{
					_userPermission.Clear();
				}
				_alreadyFetchedUserPermission = value;
			}
		}

		/// <summary> Retrieves all related entities of type 'ReportFlowEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiReportFlowCollectionViaReportHeader()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.ReportFlowCollection ReportFlowCollectionViaReportHeader
		{
			get { return GetMultiReportFlowCollectionViaReportHeader(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for ReportFlowCollectionViaReportHeader. When set to true, ReportFlowCollectionViaReportHeader is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time ReportFlowCollectionViaReportHeader is accessed. You can always execute
		/// a forced fetch by calling GetMultiReportFlowCollectionViaReportHeader(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchReportFlowCollectionViaReportHeader
		{
			get	{ return _alwaysFetchReportFlowCollectionViaReportHeader; }
			set	{ _alwaysFetchReportFlowCollectionViaReportHeader = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property ReportFlowCollectionViaReportHeader already has been fetched. Setting this property to false when ReportFlowCollectionViaReportHeader has been fetched
		/// will clear the ReportFlowCollectionViaReportHeader collection well. Setting this property to true while ReportFlowCollectionViaReportHeader hasn't been fetched disables lazy loading for ReportFlowCollectionViaReportHeader</summary>
		[Browsable(false)]
		public bool AlreadyFetchedReportFlowCollectionViaReportHeader
		{
			get { return _alreadyFetchedReportFlowCollectionViaReportHeader;}
			set 
			{
				if(_alreadyFetchedReportFlowCollectionViaReportHeader && !value && (_reportFlowCollectionViaReportHeader != null))
				{
					_reportFlowCollectionViaReportHeader.Clear();
				}
				_alreadyFetchedReportFlowCollectionViaReportHeader = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiTemplateCollectionViaTemplateToReportCategory()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.TemplateCollection TemplateCollectionViaTemplateToReportCategory
		{
			get { return GetMultiTemplateCollectionViaTemplateToReportCategory(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for TemplateCollectionViaTemplateToReportCategory. When set to true, TemplateCollectionViaTemplateToReportCategory is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time TemplateCollectionViaTemplateToReportCategory is accessed. You can always execute
		/// a forced fetch by calling GetMultiTemplateCollectionViaTemplateToReportCategory(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchTemplateCollectionViaTemplateToReportCategory
		{
			get	{ return _alwaysFetchTemplateCollectionViaTemplateToReportCategory; }
			set	{ _alwaysFetchTemplateCollectionViaTemplateToReportCategory = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property TemplateCollectionViaTemplateToReportCategory already has been fetched. Setting this property to false when TemplateCollectionViaTemplateToReportCategory has been fetched
		/// will clear the TemplateCollectionViaTemplateToReportCategory collection well. Setting this property to true while TemplateCollectionViaTemplateToReportCategory hasn't been fetched disables lazy loading for TemplateCollectionViaTemplateToReportCategory</summary>
		[Browsable(false)]
		public bool AlreadyFetchedTemplateCollectionViaTemplateToReportCategory
		{
			get { return _alreadyFetchedTemplateCollectionViaTemplateToReportCategory;}
			set 
			{
				if(_alreadyFetchedTemplateCollectionViaTemplateToReportCategory && !value && (_templateCollectionViaTemplateToReportCategory != null))
				{
					_templateCollectionViaTemplateToReportCategory.Clear();
				}
				_alreadyFetchedTemplateCollectionViaTemplateToReportCategory = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'TemplateEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiTemplateCollectionViaReportCategoryToTemplate()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.TemplateCollection TemplateCollectionViaReportCategoryToTemplate
		{
			get { return GetMultiTemplateCollectionViaReportCategoryToTemplate(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for TemplateCollectionViaReportCategoryToTemplate. When set to true, TemplateCollectionViaReportCategoryToTemplate is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time TemplateCollectionViaReportCategoryToTemplate is accessed. You can always execute
		/// a forced fetch by calling GetMultiTemplateCollectionViaReportCategoryToTemplate(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchTemplateCollectionViaReportCategoryToTemplate
		{
			get	{ return _alwaysFetchTemplateCollectionViaReportCategoryToTemplate; }
			set	{ _alwaysFetchTemplateCollectionViaReportCategoryToTemplate = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property TemplateCollectionViaReportCategoryToTemplate already has been fetched. Setting this property to false when TemplateCollectionViaReportCategoryToTemplate has been fetched
		/// will clear the TemplateCollectionViaReportCategoryToTemplate collection well. Setting this property to true while TemplateCollectionViaReportCategoryToTemplate hasn't been fetched disables lazy loading for TemplateCollectionViaReportCategoryToTemplate</summary>
		[Browsable(false)]
		public bool AlreadyFetchedTemplateCollectionViaReportCategoryToTemplate
		{
			get { return _alreadyFetchedTemplateCollectionViaReportCategoryToTemplate;}
			set 
			{
				if(_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate && !value && (_templateCollectionViaReportCategoryToTemplate != null))
				{
					_templateCollectionViaReportCategoryToTemplate.Clear();
				}
				_alreadyFetchedTemplateCollectionViaReportCategoryToTemplate = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiUserCollectionViaUserPermission()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.UserCollection UserCollectionViaUserPermission
		{
			get { return GetMultiUserCollectionViaUserPermission(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for UserCollectionViaUserPermission. When set to true, UserCollectionViaUserPermission is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time UserCollectionViaUserPermission is accessed. You can always execute
		/// a forced fetch by calling GetMultiUserCollectionViaUserPermission(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUserCollectionViaUserPermission
		{
			get	{ return _alwaysFetchUserCollectionViaUserPermission; }
			set	{ _alwaysFetchUserCollectionViaUserPermission = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property UserCollectionViaUserPermission already has been fetched. Setting this property to false when UserCollectionViaUserPermission has been fetched
		/// will clear the UserCollectionViaUserPermission collection well. Setting this property to true while UserCollectionViaUserPermission hasn't been fetched disables lazy loading for UserCollectionViaUserPermission</summary>
		[Browsable(false)]
		public bool AlreadyFetchedUserCollectionViaUserPermission
		{
			get { return _alreadyFetchedUserCollectionViaUserPermission;}
			set 
			{
				if(_alreadyFetchedUserCollectionViaUserPermission && !value && (_userCollectionViaUserPermission != null))
				{
					_userCollectionViaUserPermission.Clear();
				}
				_alreadyFetchedUserCollectionViaUserPermission = value;
			}
		}
		/// <summary> Retrieves all related entities of type 'UserEntity' using a relation of type 'm:n'.</summary>
		/// <remarks>This property is added for databinding conveniance, however it is recommeded to use the method 'GetMultiUserCollectionViaReportHeader()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the same scope.</remarks>
		public virtual CARMSData.CollectionClasses.UserCollection UserCollectionViaReportHeader
		{
			get { return GetMultiUserCollectionViaReportHeader(false); }
		}

		/// <summary> Gets / sets the lazy loading flag for UserCollectionViaReportHeader. When set to true, UserCollectionViaReportHeader is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time UserCollectionViaReportHeader is accessed. You can always execute
		/// a forced fetch by calling GetMultiUserCollectionViaReportHeader(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchUserCollectionViaReportHeader
		{
			get	{ return _alwaysFetchUserCollectionViaReportHeader; }
			set	{ _alwaysFetchUserCollectionViaReportHeader = value; }
		}
				
		/// <summary>Gets / Sets the lazy loading flag if the property UserCollectionViaReportHeader already has been fetched. Setting this property to false when UserCollectionViaReportHeader has been fetched
		/// will clear the UserCollectionViaReportHeader collection well. Setting this property to true while UserCollectionViaReportHeader hasn't been fetched disables lazy loading for UserCollectionViaReportHeader</summary>
		[Browsable(false)]
		public bool AlreadyFetchedUserCollectionViaReportHeader
		{
			get { return _alreadyFetchedUserCollectionViaReportHeader;}
			set 
			{
				if(_alreadyFetchedUserCollectionViaReportHeader && !value && (_userCollectionViaReportHeader != null))
				{
					_userCollectionViaReportHeader.Clear();
				}
				_alreadyFetchedUserCollectionViaReportHeader = value;
			}
		}




		/// <summary> Gets or sets a value indicating whether this entity is a subtype</summary>
		protected override bool LLBLGenProIsSubType
		{
			get { return false;}
		}

		/// <summary> Gets the type of the hierarchy this entity is in. </summary>
		[System.ComponentModel.Browsable(false), XmlIgnore]
		protected override InheritanceHierarchyType LLBLGenProIsInHierarchyOfType
		{
			get { return InheritanceHierarchyType.None;}
		}
		
		/// <summary>Returns the CARMSData.EntityType enum value for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override int LLBLGenProEntityTypeValue 
		{ 
			get { return (int)CARMSData.EntityType.ReportCategoryEntity; }
		}
		#endregion


		#region Custom Entity code
		
		// __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region Included code

		#endregion
	}
}
